package com.tailyou.hms.firstapp.act;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.ProgressBar;
import android.widget.SeekBar;

import com.tailyou.hms.firstapp.R;
import com.tailyou.hms.firstapp.util.CommonUtils;

public class PrgWdgActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_prg_wdg);
        ProgressBar pbC = findViewById(R.id.pbC);
        ProgressBar pbH = findViewById(R.id.pbH);
        Button btnFinish = findViewById(R.id.btnFinish);
        Button btnUpdate = findViewById(R.id.btnUpdate);
        SeekBar seekBar = findViewById(R.id.seekBar);
        btnFinish.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                pbC.setVisibility(View.GONE);
            }
        });
        btnUpdate.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                int progress = pbH.getProgress();
                if (progress < pbH.getMax()) {
                    progress += 10;
                    pbH.setProgress(progress);
                    if (progress == pbH.getMax()) {
                        CommonUtils.showToast(PrgWdgActivity.this, "加载完成");
                    }
                }
            }
        });
        seekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
            @Override
            public void onProgressChanged(SeekBar seekBar, int i, boolean b) {
                Log.d("PROGRESS", "进度为：" + i);
            }

            @Override
            public void onStartTrackingTouch(SeekBar seekBar) {
                Log.d("PROGRESS", "接触SeekBar");
            }

            @Override
            public void onStopTrackingTouch(SeekBar seekBar) {
                Log.d("PROGRESS", "松开SeekBar");
            }
        });
    }

}